<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>title</title>
<link rel="stylesheet" href="/OffTheRecord/css/bootstrap.min.css">
<link rel="stylesheet" href="/OffTheRecord/css/bootstrap-theme.min.css">
</head>
<script type="text/javascript">
	$(document).ready(function() {
		
		$("#myModal").modal('show');
		
	});
	
	function insertIC(id){
		$.ajax({
			type: "post",
			url: "/OffTheRecord/addInterestCompany.action",
			data: "companyId="+id,
			dataType:"json",
			
			success:function(data){
					alert(data.message);
			}
		});//ajax
	}
	
	
	function checkCompany(){
		var list =[];
		"<c:forEach items="${requestScope.clist}" var="list">";
			list.push("${list.companyName}");
		"</c:forEach>";
		var companyName = $('#company_name').val();
		var flag = 0;
		for(var i=0; i<list.length; i++){
			if(list[i] == companyName){
				flag=1;
				document.location.href="/OffTheRecord/searchCompanyByName.action?companyName="+companyName;
				return true;
			}
		}
		if(flag == 0){
			alert("카테고리네에 해당 기업이 없습니다.");
			$('#company_name').val("");
			$('#company_name').focus();
			return false;
		}
		if(companyName == ""){
			alert("회사명을 입력해주세요!");
			$('#company_name').focus();
			return false;
		}
	}
</script>
<script type="text/javascript">
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch (e) {
	}
</script>
<script type="text/javascript"
	src="http://openapi.map.naver.com/openapi/naverMap.naver?ver=2.0&key=eea58cb0ba5119c6f1e3c8bd57d276dd"></script>
<body>
	<c:import url="../common/top.jsp"></c:import>
	<div class="container" style="margin: 60px;"></div>

	<div class="container">
		<div class="row">

			<!-- 왼쪽 -->
			<div class="col-lg-1"></div>
			<div class="col-xs-3 col-sm-2 col-md-2 col-lg-2
			"
				style="margin-left: -105px">

				<div class="panel-group" id="accordion a1">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h4 class="panel-title">
								산업별 <a class="accordion-toggle" data-toggle="collapse"
									data-parent="#accordion a1" href="#collapseOne"> <span
									class="glyphicon glyphicon-plus" style="float: right;"></span>
								</a>
							</h4>
						</div>
						<c:choose>
							<c:when
								test="${requestScope.flag == null || requestScope.flag == 'industry'}">
								<div id="collapseOne" class="panel-collapse collapse in">
									<div class="panel-body" style="margin: 1px; padding: 1px;">
										<div class="list-group">
											<c:forEach items="${ilist }" var="i">
												<a
													href="/OffTheRecord/getCompanyByIndustryName.action?industryName=${i.industryName }&&pageNo=1"
													class="list-group-item">${i.industryName }</a>
											</c:forEach>
										</div>
									</div>
								</div>
							</c:when>
							<c:otherwise>
								<div id="collapseOne" class="panel-collapse collapse">
									<div class="panel-body" style="margin: 1px; padding: 1px;">
										<div class="list-group">
											<c:forEach items="${ilist }" var="i">
												<a
													href="/OffTheRecord/getCompanyByIndustryName.action?industryName=${i.industryName }&&pageNo=1"
													class="list-group-item">${i.industryName }</a>
											</c:forEach>
										</div>
									</div>
								</div>
							</c:otherwise>
						</c:choose>
					</div>
				</div>

				<div class="panel-group" id="accordion">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h4 class="panel-title">
								평점별 <a data-toggle="collapse" data-parent="#accordion"
									href="#collapse2"> <span class="glyphicon glyphicon-plus"
									style="float: right;"></span>
								</a>
							</h4>
						</div>
						<c:choose>
							<c:when test="${requestScope.flag == 'score'}">
								<div id="collapse2" class="panel-collapse collapse in">
									<div class="panel-body" style="margin: 1px; padding: 1px;">
										<div class="list-group">
											<a href="/OffTheRecord/getCompanyByTotalScore.action?pageNo=1"
												class="list-group-item">총 만족도</a> <a
												href="/OffTheRecord/getCompanyByScoreChance.action?pageNo=1"
												class="list-group-item"><b><font size="2">승진
														기회 및 가능성</font></b></a> <a
												href="/OffTheRecord/getCompanyByScoreWelfare.action?pageNo=1"
												class="list-group-item"><b><font size="2">복지
														및 급여</font></b></a> <a
												href="/OffTheRecord/getCompanyByScoreOverdue.action?pageNo=1"
												class="list-group-item"><b><font size="2">초과
														근무</font></b></a> <a href="/OffTheRecord/getCompanyByScoreHoliday.action?pageNo=1"
												class="list-group-item"><b><font size="2">휴가
														자율성</font></b></a> <a
												href="/OffTheRecord/getCompanyByScoreCulture.action?pageNo=1"
												class="list-group-item"><b><font size="2">사내
														문화</font></b></a> <a
												href="/OffTheRecord/getCompanyByScoreExecutive.action?pageNo=1"
												class="list-group-item"><b><font size="2">경영진</font></b></a>
										</div>
									</div>
								</div>
							</c:when>
							<c:otherwise>
								<div id="collapse2" class="panel-collapse collapse">
									<div class="panel-body" style="margin: 1px; padding: 1px;">
										<div class="list-group">
											<a href="/OffTheRecord/getCompanyByTotalScore.action?pageNo=1"
												class="list-group-item">총 만족도</a> <a
												href="/OffTheRecord/getCompanyByScoreChance.action?pageNo=1"
												class="list-group-item"><b><font size="2">승진
														기회 및 가능성</font></b></a> <a
												href="/OffTheRecord/getCompanyByScoreWelfare.action?pageNo=1"
												class="list-group-item"><b><font size="2">복지
														및 급여</font></b></a> <a
												href="/OffTheRecord/getCompanyByScoreOverdue.action?pageNo=1"
												class="list-group-item"><b><font size="2">초과
														근무</font></b></a> <a href="/OffTheRecord/getCompanyByScoreHoliday.action?pageNo=1"
												class="list-group-item"><b><font size="2">휴가
														자율성</font></b></a> <a
												href="/OffTheRecord/getCompanyByScoreCulture.action?pageNo=1"
												class="list-group-item"><b><font size="2">사내
														문화</font></b></a> <a
												href="/OffTheRecord/getCompanyByScoreExecutive.action?pageNo=1"
												class="list-group-item"><b><font size="2">경영진</font></b></a>
										</div>
									</div>
								</div>
							</c:otherwise>
						</c:choose>


					</div>
				</div>

				<div class="panel-group" id="accordion">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h4 class="panel-title">
								지역별 <a data-toggle="collapse" data-parent="#accordion"
									href="#collapse3"> <span class="glyphicon glyphicon-plus"
									style="float: right;"></span>
								</a>
							</h4>
						</div>
						<c:choose>
							<c:when test="${requestScope.flag == 'region'}">
								<div id="collapse3" class="panel-collapse collapse in">
									<div class="panel-body" style="margin: 1px; padding: 1px;">
										<div class="list-group">
											<c:forEach items="${rlist}" var="r">
												<a
													href="/OffTheRecord/getCompanyByRegionName.action?regionName=${r.regionName }&&pageNo=1"
													class="list-group-item">${r.regionName }</a>
											</c:forEach>

										</div>
									</div>
								</div>
							</c:when>
							<c:otherwise>
								<div id="collapse3" class="panel-collapse collapse">
									<div class="panel-body" style="margin: 1px; padding: 1px;">
										<div class="list-group">
											<c:forEach items="${rlist}" var="r">
												<a
													href="/OffTheRecord/getCompanyByRegionName.action?regionName=${r.regionName }&&pageNo=1"
													class="list-group-item">${r.regionName }</a>
											</c:forEach>

										</div>
									</div>
								</div>
							</c:otherwise>
						</c:choose>
					</div>
				</div>

			</div>
			<!-- 왼쪽 -->

			<!-- 오른쪽 -->
			<div class="right col-xs-8 col-sm-8 col-md-8 col-lg-8">
				<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"></div>
				<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"
					style="margin-left: 750px; position: fixed;">
					<div class="input-group">
						<form id="searchForm" name="searchForm" method="post"
							onsubmit="checkCompany(); return false;">
							- 카테고리 내 검색 <br> <input type="text" class="form-control"
								id="company_name" name="companyName" list="company"
								placeholder="회사명으로 검색해주세요." style="width: 200px">
							<datalist id="company"> <c:forEach items="${clist}"
								var="clist">
								<option label="${clist.companyName}"
									value="${clist.companyName}" />
							</c:forEach> </datalist>
							&nbsp; <input type="submit" id="searchBtn"
								class="btn btn-default" value="검색" />
						</form>
					</div>
				</div>
				<c:choose>
					<c:when test="${fn:length(name) == 0 }">
						<c:choose>
							<c:when test="${fn:length(clist) == 0 }">
								회사가 없습니다.
							</c:when>
							<c:otherwise>
								<c:forEach items="${clist }" var="list">

									<div class="right-view col-xs-12 col-sm-12 col-md-12 col-lg-12"
										style="border: 1px solid lightgray; border-radius: 5px; margin-bottom: 10px; padding: 5px;">

										<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"
											onclick="location.href='/OffTheRecord/getCompanyReview.action?pageNo=1&&companyId=${list.companyId }'">

											<div class="company-img col-xs-2"
												onclick="location.href='/OffTheRecord/getCompanyReview.action?pageNo=1&&companyId=${list.companyId }'"
												style="padding: 5px;">
												<c:if test="${list.companyCi == '0' }">
													<img class="img-responsive"
														src="/OffTheRecord/company_ci/${list.companyCi }.png">
												</c:if>
												<c:if test="${list.companyCi != '0' }">
													<img class="img-responsive"
														src="/OffTheRecord/company_ci/${list.companyCi }">
												</c:if>
											</div>

											<div class="col-xs-10"
												onclick="location.href='/OffTheRecord/getCompanyReview.action?pageNo=1&&companyId=${list.companyId }'">
												<h2>${list.companyName}</h2>
												<c:set var="total_score" value="${list.companyTotalScore}" />
												<c:set var="total_score_round"
													value="${ total_score+((total_score%1>0.5)?(1-(total_score%1))%1:-(total_score%1)) }" />
												<!-- 색깔있는 별 -->
												<c:forEach begin="1" end="${total_score_round}">
													<span><img alt="" src="/OffTheRecord/img/star1.png"></span>
												</c:forEach>
												<!-- 회색 별 -->
												<c:forEach begin="1" end="${5-total_score_round }">
													<span><img alt="" src="/OffTheRecord/img/star2.png"></span>
												</c:forEach>
												<font style="font-weight: bold;">${list.companyTotalScore}점</font>
											</div>

										</div>

										<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8"
											style="padding-bottom: 10px;">
											<br> 대표자 : ${list.companyPresident }<br> 주소 :
											${list.companyAddress }
											<c:if test="${fn:length(list.companyX) != 0}">
												<a data-toggle="modal" href="#myModal"
													class="btn btn-success btn-xs"> 위치정보 보기 <c:set
														value="${list.companyX }" var="x" /> <c:set
														value="${list.companyY }" var="y" /> <span
													class="glyphicon glyphicon-search"></span>
												</a>
											</c:if>
											<br> 홈페이지 : <a href="http://${list.companyUrl }">${list.companyUrl }</a>
											<br>
										</div>

										<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
											매출액 : ${list.companySales }백만원<br> 연봉 :
											${list.companySalary }만원<br> <a href="#"
												onclick="insertIC(${list.companyId })" type="button"
												class="btn btn-danger btn-sm"> 관심기업 추가하기 <span
												class="glyphicon glyphicon-star"></span>
											</a>
										</div>
									</div>
								</c:forEach>
							</c:otherwise>
						</c:choose>
					</c:when>
					<c:when test="${flag == 'score'}">
						<c:choose>
							<c:when test="${fn:length(cclist) == 0 }">
								회사가 없습니다.
							</c:when>
							<c:otherwise>
								<c:forEach items="${cclist }" var="list">

									<div class="right-view col-xs-12 col-sm-12 col-md-12 col-lg-12"
										style="border: 1px solid lightgray; border-radius: 5px; margin-bottom: 10px; padding: 5px;">

										<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"
											onclick="location.href='/OffTheRecord/getCompanyReview.action?pageNo=1&&companyId=${list.companyId }'">

											<div class="company-img col-xs-2"
												onclick="location.href='/OffTheRecord/getCompanyReview.action?pageNo=1&&companyId=${list.companyId }'"
												style="padding: 5px;">
												<c:if test="${list.companyCi == '0' }">
													<img class="img-responsive"
														src="/OffTheRecord/company_ci/${list.companyCi }.png">
												</c:if>
												<c:if test="${list.companyCi != '0' }">
													<img class="img-responsive"
														src="/OffTheRecord/company_ci/${list.companyCi }">
												</c:if>
											</div>

											<div class="col-xs-10"
												onclick="location.href='/OffTheRecord/getCompanyReview.action?pageNo=1&&companyId=${list.companyId }'">
												<h2>${list.companyName}</h2>
												<c:set var="total_score" value="${list.companyTotalScore}" />
												<c:set var="total_score_round"
													value="${ total_score+((total_score%1>0.5)?(1-(total_score%1))%1:-(total_score%1)) }" />
												<!-- 색깔있는 별 -->
												<c:forEach begin="1" end="${total_score_round}">
													<span><img alt="" src="/OffTheRecord/img/star1.png"></span>
												</c:forEach>
												<!-- 회색 별 -->
												<c:forEach begin="1" end="${5-total_score_round }">
													<span><img alt="" src="/OffTheRecord/img/star2.png"></span>
												</c:forEach>
												<font style="font-weight: bold;">${list.companyTotalScore}점</font>
											</div>

										</div>

										<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8"
											style="padding-bottom: 10px;">
											<br> 대표자 : ${list.companyPresident }<br> 주소 :
											${list.companyAddress }
											<c:if test="${fn:length(list.companyX) != 0}">
												<a data-toggle="modal" href="#myModal"
													class="btn btn-success btn-xs"> 위치정보 보기 <c:set
														value="${list.companyX }" var="x" /> <c:set
														value="${list.companyY }" var="y" /> <span
													class="glyphicon glyphicon-search"></span>
												</a>
											</c:if>
											<br> 홈페이지 : <a href="http://${list.companyUrl }">${list.companyUrl }</a>
											<br>
										</div>

										<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
											매출액 : ${list.companySales }백만원<br> 연봉 :
											${list.companySalary }만원<br> <a href="#"
												onclick="insertIC(${list.companyId })" type="button"
												class="btn btn-danger btn-sm"> 관심기업 추가하기 <span
												class="glyphicon glyphicon-star"></span>
											</a>
										</div>
									</div>
								</c:forEach>
								<div align="center">
								<c:forEach var="i" begin="1" end="${page }">
								<c:choose>
                                       <c:when test="${nowPage != i}">
                                          <a href="/OffTheRecord/${name }?pageNo=${i}">${i}</a>
                                       </c:when>
                                       <c:otherwise>
                                       ${i}
                                       </c:otherwise>
                                    </c:choose>
									&nbsp;
								</c:forEach>
								</div>
							</c:otherwise>
						</c:choose>
					</c:when>
					<c:otherwise>
						<c:choose>
							<c:when test="${fn:length(cclist.list) == 0 }">
						회사가 없습니다.
							</c:when>
							<c:otherwise>
								<c:forEach items="${cclist.list }" var="list">

									<div class="right-view col-xs-12 col-sm-12 col-md-12 col-lg-12"
										style="border: 1px solid lightgray; border-radius: 5px; margin-bottom: 10px; padding: 5px;">

										<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"
											onclick="location.href='/OffTheRecord/getCompanyReview.action?pageNo=1&&companyId=${list.companyId }'">

											<div class="company-img col-xs-2"
												onclick="location.href='/OffTheRecord/getCompanyReview.action?pageNo=1&&companyId=${list.companyId }'"
												style="padding: 5px;">
												<c:if test="${list.companyCi == '0' }">
													<img class="img-responsive"
														src="/OffTheRecord/company_ci/${list.companyCi }.png">
												</c:if>
												<c:if test="${list.companyCi != '0' }">
													<img class="img-responsive"
														src="/OffTheRecord/company_ci/${list.companyCi }">
												</c:if>
											</div>

											<div class="col-xs-10"
												onclick="location.href='/OffTheRecord/getCompanyReview.action?pageNo=1&&companyId=${list.companyId }'">
												<h2>${list.companyName}</h2>
												<c:set var="total_score" value="${list.companyTotalScore}" />
												<c:set var="total_score_round"
													value="${ total_score+((total_score%1>0.5)?(1-(total_score%1))%1:-(total_score%1)) }" />
												<!-- 색깔있는 별 -->
												<c:forEach begin="1" end="${total_score_round}">
													<span><img alt="" src="/OffTheRecord/img/star1.png"></span>
												</c:forEach>
												<!-- 회색 별 -->
												<c:forEach begin="1" end="${5-total_score_round }">
													<span><img alt="" src="/OffTheRecord/img/star2.png"></span>
												</c:forEach>
												<font style="font-weight: bold;">${list.companyTotalScore}점</font>
											</div>

										</div>

										<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8"
											style="padding-bottom: 10px;">
											<br> 대표자 : ${list.companyPresident }<br> 주소 :
											${list.companyAddress }
											<c:if test="${fn:length(list.companyX) != 0}">
												<a data-toggle="modal" href="#myModal"
													class="btn btn-success btn-xs"> 위치정보 보기 <c:set
														value="${list.companyX }" var="x" /> <c:set
														value="${list.companyY }" var="y" /> <span
													class="glyphicon glyphicon-search"></span>
												</a>
											</c:if>
											<br> 홈페이지 : <a href="http://${list.companyUrl }">${list.companyUrl }</a>
											<br>
										</div>

										<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
											매출액 : ${list.companySales }백만원<br> 연봉 :
											${list.companySalary }만원<br> <a href="#"
												onclick="insertIC(${list.companyId })" type="button"
												class="btn btn-danger btn-sm"> 관심기업 추가하기 <span
												class="glyphicon glyphicon-star"></span>
											</a>
										</div>
									</div>
								</c:forEach>
								<hr>
								<p>

									<c:set var="pb" value="${ cclist.pagingBean }" />

									<c:if test="${ pb.previousPageGroup }">
										<c:if test="${flag == 'industry' }">
											<a
												href="/OffTheRecord/getCompanyByIndustryName.action?industryName=${name }&&pageNo=${ pb.startPageOfPageGroup-1 }">
												<img src="/OffTheRecord/img/left_arrow_btn.gif">
											</a>
										</c:if>
										<c:if test="${flag == 'region' }">
											<a
												href="/OffTheRecord/getCompanyByRegionName.action?regionName=${name }&&pageNo=${ pb.startPageOfPageGroup-1 }">
												<img src="/OffTheRecord/img/left_arrow_btn.gif">
											</a>
										</c:if>
									</c:if>
								<div align="center">
									<c:forEach var="i" begin="${ pb.startPageOfPageGroup }"
										end="${ pb.endPageOfPageGroup }">
										<c:choose>
											<c:when test="${ pb.nowPage!=i }">
												<c:if test="${flag == 'industry' }">
													<a
														href="/OffTheRecord/getCompanyByIndustryName.action?industryName=${name }&&pageNo=${i}">${i}</a>
												</c:if>
												<c:if test="${flag == 'region' }">
													<a
														href="/OffTheRecord/getCompanyByRegionName.action?regionName=${name }&&pageNo=${i}">${i}</a>
												</c:if>
											</c:when>
											<c:otherwise>
													${i}
													</c:otherwise>
										</c:choose>
												&nbsp;
											</c:forEach>
								</div>

								<c:if test="${ pb.nextPageGroup }">
									<c:if test="${flag == 'industry' }">
										<a
											href="/OffTheRecord/getCompanyByIndustryName.action?industryName=${name }&&pageNo=${ pb.endPageOfPageGroup+1 }">
											<img src="/OffTheRecord/img/right_arrow_btn.gif">
										</a>
									</c:if>
									<c:if test="${flag == 'region' }">
										<a
											href="/OffTheRecord/getCompanyByRegionName.action?regionName=${name }&&pageNo=${ pb.startPageOfPageGroup+1 }">
											<img src="/OffTheRecord/img/right_arrow_btn.gif">
										</a>

									</c:if>
								</c:if>
								<br>
								<br>
							</c:otherwise>
						</c:choose>
					</c:otherwise>
				</c:choose>
			</div>
			<!-- 오른쪽 -->

			<div class="col-lg-1"></div>
		</div>
		<!-- row -->
	</div>
	<!-- container -->

	<!-- <div id="map"></div> -->
	<div id="myModal" class="modal fade">
		<div class="modal-dialog">
			<div class="modal-content">
				<div id="map" class="modal-body" style="height: 350px;"></div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		var x="<c:out value="${x}" />";
		var y="<c:out value="${y}" />";
		var oPoint = new nhn.api.map.LatLng(y, x); //LatLng 값이 y, x 좌표
		nhn.api.map.setDefaultPoint('LatLng');
		oMap = new nhn.api.map.Map('map', { //표시될 div의 id 입니다.
			point : oPoint,
			zoom : 11, //기본 지도 줌 크기
			enableWheelZoom : true,
			enableDragPan : true,
			enableDblClickZoom : false,
			mapMode : 0,
			activateTrafficMap : false,
			activateBicycleMap : false,
			minMaxLevel : [ 1, 14 ],
			size : new nhn.api.map.Size(690, 338)
		//표시될 지도 크기
		});
		//아래는 위에서 지정한 좌표에 마커를 표시하는 소스 입니다.
		var oSize = new nhn.api.map.Size(28, 37);
		var oOffset = new nhn.api.map.Size(14, 37);
		var oIcon = new nhn.api.map.Icon(
				'http://static.naver.com/maps2/icons/pin_spot2.png', oSize,
				oOffset);
		//icon 이미지를 바꿔서 사용할 수 있습니다.
		var oMarker = new nhn.api.map.Marker(oIcon, {
			title : '타이틀'
		});
		oMarker.setPoint(oPoint);
		oMap.addOverlay(oMarker);
		//아래는 사이드에 줌 컨트롤을 추가하는 소스 입니다.
		var mapZoom = new nhn.api.map.ZoomControl(); // - 줌 컨트롤 선언
		mapZoom.setPosition({
			left : 20,
			bottom : 40
		}); // - 줌 컨트롤 위치 지정
		oMap.addControl(mapZoom); // - 줌 컨트롤 추가.
	</script>
	<script
		src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
	<script
		src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</body>
</html>